<template>
	<view>
		<view class="title">
			<u-search placeholder="请输入内容" v-model="keyword"></u-search>
		</view>
		<view class="conent">
			<view class="conent1">
				<ul>
					<li :class="flg==i?'active':''" @click="tab(i)" v-for="(item,i) in list" :key="item.id">
						{{item.catename}}
					</li>
				</ul>
			</view>
			<view class="conent2">
				<view class="yous">
					<text class="h2">热门精选</text>
					<view>
						<u-grid :border="false"  @click="arr">
							<u-grid-item v-for="(baseListItem,baseListIndex) in baseList" :key="baseListIndex">
								<image class="img1" :src="'http://localhost:3000' + baseListItem.img" mode=""></image>
								<text class="grid-text">{{baseListItem.catename}}</text>
							</u-grid-item>
						</u-grid>
						<u-toast ref="uToast" />
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getHomeCates
	} from '../../reuqust/api.js'
	export default {
		data() {
			return {
				list: [],
				baseList: [],
				flg: ''
			}
		},
		onLoad() {
			this.getHomeCatesList()
		},
		methods: {
			async getHomeCatesList() {
				let res = await getHomeCates()
				console.log(res, '1111');
				if (res.data.code == 200) {
					this.list = res.data.list
					this.baseList = res.data.list[0].children
				}
			},
			tab(i) {
				console.log(i, '222');
				this.baseList = this.list[i].children
				this.flg = i
			},
			arr(name){
				let i = this.baseList[name].id
				uni.navigateTo({
					url:'../list/list?id='+i+"&type="+2
				})
			}
		}
	}
</script>

<style lang="scss">
	.active {
		color: #ff6040;
	}

	* {
		list-style: none;
	}

	page {
		background: #f2f2f2;
	}

	.title {
		background-color: red;
	}

	.conent {
		display: flex;
	}

	.conent1 {
		width: 240rpx;
		background: #fff;
	}

	.conent1 ul {
		height: 1200rpx;
	}

	.conent1 ul li {
		padding-top: 60rpx;
		font-size: 40rpx;
		// color: #999;
		text-align: center;
		line-height: 60rpx;
	}

	.conent2 {
		margin: 10rpx auto;
	}

	.conent2 .yous {
		background-color: #f2f2f2;
		width: 480rpx;
		height: 418rpx;
		background-color: white;
		margin: 20rpx auto;
		display: flex;
		flex-direction: column;
	}

	.conent2 .yous .h2 {
		font-size: 32rpx;
		color: #333333;
		line-height: 32rpx;
		margin-top: 20rpx;
		margin-left: 20rpx;
	}

	.tu {
		width: 464rpx;
		height: 436rpx;
		background-color: white;
	}

	.tu ul {
		display: flex;
		width: 464rpx;
		// justify-content: space-evenly;
		margin-top: 28rpx;
	}

	.img1 {
		width: 128rpx;
		height: 128rpx;
		margin-left: 20rpx;
		margin-top: 10rpx;
	}

	// .tu ul li .ppp {
	// 	font-size: 24rpx;
	// 	/* color: #999999; */
	// 	text-align: center;
	// 	line-height: 24rpx;
	// 	margin-top: 10rpx;
	// }

	.grid-text {
		font-size: 14px;
		color: #909399;
		padding: 10rpx 0 20rpx 0rpx;
		/* #ifndef APP-PLUS */
		box-sizing: border-box;
		/* #endif */
	}
</style>
